<?php
		global $_W, $_GPC;
			load()->func('tpl');
		$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
		$opp = 'cityclass';
		$uniacid = $_W['uniacid'];
		if ($operation == 'display') {
			
			$list = pdo_fetchall("SELECT * FROM " . tablename('bbyscm_card_cityclass') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY id DESC");
			
			if (!empty($list)) {
            foreach ($list as $key => $card) {
            $list[$key]['thumb'] = tomedia($card['thumb']);
           
              }
		  }
		
		}elseif ($operation == 'shenhe'){
			$id = intval($_GPC['id']);
			$issend = intval($_GPC['displayk']) == 1 ? 0 : 1;
			$data1 = array('displayk' => $issend);
			pdo_update('bbyscm_card_cityclass', $data1, array('id' => $id));
			if ($issend == 1) {
				echo json_encode(array('a' => 1));
				return NULL;
			}
			echo json_encode(array('a' => 0));
			return NULL;
		} elseif ($operation == 'post') {
			$id = $_GPC['id'];
			if (checksubmit('submit')) {
				$data = array(
					'uniacid' => $_W['uniacid'],
					'porder' => $_GPC['porder'],
					'classname' => $_GPC['classname'],
					'paymoney' => $_GPC['paymoney'],
					'thumb' => $_GPC['thumb'],
					'displayk' => $_GPC['displayk'],
					'to' => $_GPC['to'],
				);
				if (!empty($id)) {
					pdo_update('bbyscm_card_cityclass', $data, array('id' => $id));
				} else {
					pdo_insert('bbyscm_card_cityclass', $data);
					$id = pdo_insertid();
				}
				message('更新成功！', $this->createWebUrl('cityclass', array('op' => 'display')), 'success');
			}
			$cityc = pdo_fetch("select * from " . tablename('bbyscm_card_cityclass') . " where id=:id and uniacid=:uniacid limit 1", array(":id" => $id, ":uniacid" => $_W['uniacid']));
		} elseif ($operation == 'delete') {
			$id = intval($_GPC['id']);
			$cityc = pdo_fetch("SELECT id FROM " . tablename('bbyscm_card_cityclass') . " WHERE id = '$id' AND uniacid=" . $_W['uniacid'] . "");
			if (empty($cityc)) {
				message('抱歉，不存在或是已经被删除！', $this->createWebUrl('cityclass', array('op' => 'display')), 'error');
			}
			pdo_delete('bbyscm_card_cityclass', array('id' => $id));
			message('删除成功！', $this->createWebUrl('cityclass', array('op' => 'display')), 'success');
		} else {
			message('请求方式不存在');
		}
		include $this->template('web/cityclass');
	
